<?php

namespace App\Http\Controllers\Api;

use App\Events\addLog;
use App\Models\School;
use App\Models\Student;
use App\Http\Controllers;
use Illuminate\Support\Facades\Auth;

class AllEnrollController extends Controllers\Controller
{

    public function allEnroll($id)
    {
        $school = School::query()->where('id',$id)->first();
        if($school->is_import ==0){
            $students = Student::query()->where('school_id',$school->school_code)->get();
            foreach ($students as $student){
                $student->is_enroll = 1;
                $student->save();
            }
            event(new addLog(Auth::user(),'提交了'.$school->school_name.'全部录取'));
        }
    }
}
